package com.perfect;

import com.perfect.mapper.UserMapper;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;

import java.io.InputStream;

import static org.apache.logging.log4j.core.util.Loader.getClassLoader;


/**
 * 单独使用mybatis
 */
public class Test {
    public static void main(String[] args) {


        try {
            InputStream is = Test.class.getClassLoader().getResourceAsStream("mybatis.xml");
            SqlSessionFactory sqlSessionFactory = new SqlSessionFactoryBuilder().build(is);
            SqlSession sqlSession = sqlSessionFactory.openSession();

            UserMapper userMapper = sqlSession.getMapper(UserMapper.class);
            System.out.println(userMapper.getUserNameById());
            System.out.println(userMapper.getUserNameById());
            System.out.println(userMapper.getUserNameById());
        }catch (Exception e){
            e.printStackTrace();
        }



    }
}